#include "server.h"
#include "IOContextPool.h"

#include <csignal>
#include <thread>
#include <mutex>
#include <iostream>

int main()
{
    try
    {
        auto& pool = IOContextPool::GetInstance();
        boost::asio::io_context io_context;
        boost::asio::signal_set signals(io_context, SIGINT, SIGTERM);
        signals.async_wait([&io_context, &pool](auto, auto) 
        {
             io_context.stop();
             pool.stop(); 
        });

        Server s(io_context, 8080);
        io_context.run();
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what() << '\n';
    }
}